package com.smartalarmclock.Model;

import com.smartalarmclock.Model.Exceptions.InvalidNullReferenceOnDeleteException;
import com.smartalarmclock.Model.Exceptions.InvalidReferenceToRemoveException;

import android.content.Context;

interface IReferencingDataEntity extends IDataEntity {
	
	/**
	 * Checks if the given entity is actually referenced by the the referencing entity
	 * @param context the context of the request
	 * @param referencedEntity the referenced entity.
	 * @return true if the entity is referenced, otherwise false.
	 */
	boolean IsReferenced(Context context, IReferencedDataEntity referencedEntity);
	
	/**
	 * Checks if the removal of the reference is valid. If not this means that the reference cannot be null.
	 * @param context the context of the request
	 * @param referencedEntity the referenced entity.
	 * @return true if the entity can be removed safely, otherwise false.
	 */
	boolean CanRemoveReference(Context context, IReferencedDataEntity referencedEntity);
	
	/**
	 * Removes the reference of the referenced data entity.
	 * @param context the context of the request
	 * @param referencedEntity the referenced entity.
	 * @throws InvalidNullReferenceOnDeleteException if the reference cannot be null and the removal is invalid.
	 * @throws InvalidReferenceToRemoveException if the referenced entity is not referenced at all.
	 */
	void RemoveReference(Context context, IReferencedDataEntity referencedEntity) throws InvalidNullReferenceOnDeleteException, InvalidReferenceToRemoveException;
}
